package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.TbServiceContent;
import com.ruoyi.system.service.ITbServiceContentService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 服务内容Controller
 * 
 * @author lzd
 * @date 2024-09-09
 */

@RestController
@RequestMapping("/serviceContent")
public class TbServiceContentController extends BaseController
{
    @Autowired
    private ITbServiceContentService tbServiceContentService;

    /**
     * 查询服务内容列表
     */
//    @RequiresPermissions("system:serviceContent:list")
    @GetMapping("/list")
    public TableDataInfo list(TbServiceContent tbServiceContent)
    {
        startPage();
        List<TbServiceContent> list = tbServiceContentService.selectTbServiceContentList(tbServiceContent);
        return getDataTable(list);
    }

    /**
     * 导出服务内容列表
     */
    @RequiresPermissions("system:serviceContent:export")
    @Log(title = "服务内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbServiceContent tbServiceContent)
    {
        List<TbServiceContent> list = tbServiceContentService.selectTbServiceContentList(tbServiceContent);
        ExcelUtil<TbServiceContent> util = new ExcelUtil<TbServiceContent>(TbServiceContent.class);
        util.exportExcel(response, list, "服务内容数据");
    }

    /**
     * 获取服务内容详细信息
     */
    @RequiresPermissions("system:serviceContent:query")
    @GetMapping(value = "/{serviceId}")
    public AjaxResult getInfo(@PathVariable("serviceId") Long serviceId)
    {
        return success(tbServiceContentService.selectTbServiceContentByServiceId(serviceId));
    }

    /**
     * 新增服务内容
     */
    @RequiresPermissions("system:serviceContent:add")
    @Log(title = "服务内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbServiceContent tbServiceContent)
    {
        return toAjax(tbServiceContentService.insertTbServiceContent(tbServiceContent));
    }

    /**
     * 修改服务内容
     */
    @RequiresPermissions("system:serviceContent:edit")
    @Log(title = "服务内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbServiceContent tbServiceContent)
    {
        return toAjax(tbServiceContentService.updateTbServiceContent(tbServiceContent));
    }

    /**
     * 删除服务内容
     */
    @RequiresPermissions("system:serviceContent:remove")
    @Log(title = "服务内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{serviceIds}")
    public AjaxResult remove(@PathVariable Long[] serviceIds)
    {
        return toAjax(tbServiceContentService.deleteTbServiceContentByServiceIds(serviceIds));
    }
}
